So I made a little code snippet that will animate the GCColor. Just add it to your class and call animate(to:,duration:,completion:) to animate the DualShock controller's color.
var completions: [() -> ()] = []
func animate(to color: GCColor, duration: TimeInterval, _ completion: (() -> ())? = nil) {
completions.removeAll()
let currentColor = controller.light!.color
let diff = (color.red - currentColor.red, color.green - currentColor.green, color.blue - currentColor.blue)
let steps = Int(duration * 20)
for i in 0..<steps {
completions.append {
self.controller.light?.color = GCColor(red: currentColor.red + Float(i) * diff.0 / Float(steps),
green: currentColor.green + Float(i) * diff.1 / Float(steps),
blue: currentColor.blue + Float(i) * diff.2 / Float(steps))
self.completions.removeFirst()
self.animate(steps: steps, duration: duration, completion)
}
}
completions.first?()
}
func animate(steps: Int, duration: TimeInterval, _ completion: (() -> ())?) {
DispatchQueue.main.asyncAfter(deadline: .now() + duration / Double(steps)) {
if self.completions.isEmpty {
completion?()
} else {
self.completions.first?()
}
}
}
Post
Replies
Boosts
Views
Activity
So I've just made this into a gist - https://gist.github.com/RomanEsin/968c1bb76235f8002bd254296d486a64!
“Hi, was also having this issue and found a fix. I have a 2019 MBP 16” and noticed that trackpad, internal keyboard, Touch Bar, USB mouse, etc. all stopped working. What fixed it for me was to take all extensions in the /Library/Extensions folder and delete them from that directory and place them on my desktop. I then restarted my computer and once it was done I found that everything started working once again. After this, I placed all of the kext extensions back into the original directory and restarted. Even after placing them all back, everything works as it should :)”
Original post from /u/theolaw on Reddit.